<?php
use \PsiFramework\Classes\Util\UI\Printer;
use \PsiFramework\Classes\Util\UI\HTML;

$entry = $response->getAttribute("entry");
$category = $response->getAttribute("category");
if (is_null($category) && !is_null($entry)) $category = $entry->getCategory();

$themePoints = $response->getAttribute('themePoints');
$totalPoints = $response->getAttribute('totalPoints');

$note = $templateManager->getParameter('note');
if (is_null($note)) $note = 0 ;

?>
<article id="cont-princ" class="cols">
    <h1><?php Printer::display($languageManager->getText('GAUGE_TITLE')); ?></h1>
    <h3><?php Printer::display($languageManager->getText('GAUGE_SUBTITLE')); ?></h3>
    <p>
        <?php Printer::display($languageManager->getText('GAUGE_TEXT')); ?>
    </p>
    <?php 
    if (count($themePoints)>0) {
    ?>
    <h3><?php Printer::display($languageManager->getText('THEMES_TO_UNLOCK')); ?></h3>
    <p>
        <?php Printer::display($languageManager->getText('THEMES_TO_UNLOCK_TEXT')); ?>
    </p>
    <p>
        <?php Printer::display($languageManager->getText('CURRENT_NOTE').' : '.$note.'%'); ?> 
    </p>
    <ul>
    <?php 
        foreach ($themePoints as $themePoint) {
            $theme = $themePoint['theme'];
            $part = $themePoint['part'];
            $responseId = $themePoint['responseId'];
            
            $unlock = false;
            $link
                = "action=EditProfile&entry_id=".$entry->getId().
                "&form_id=".$theme->getId();
            
            if (!is_null($responseId) && !$responseId->isActive() && !$part->isFree()) {
            	$link
                	= "action=ShowTheme&entry_id=".$entry->getId().
                	"&form_id=".$theme->getId();
            	$unlock = true;
            }
            
            $text = $theme->getTitle();
            
            $points = $part->getPoints();
            if (!isNullOrEmptyString($points) && $points>0) {
               
                $percentage = round(($points/$totalPoints)*100);
    ?>
        <li>
            <?php
            echo HTML::link($text, $link);
            Printer::display(' (+'.$percentage.'%)');
            
            if ($unlock) {
            ?>
            <a href="<?php Printer::display(HTML::linkHref($link)); ?>" >
                <img src="./Images/AlloMedia/panier/ico_lock.png" />
            </a>
			<?php 
            }
			?>
        </li>
    <?php
            }
        }
    ?>
    </ul>
    <?php 
    }
    ?>
</article>
